﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Common;

namespace FlexConta.DataAccess.DataModel
{
    public class DataContext : DbContext
    {
        // Constructor
        public DataContext(String connectionString)
            : base(connectionString) 
        {
            Initialize();
        }

        public DataContext(DbConnection connection)
            : base(connection, false)
        {
            Initialize();
        }

        private void Initialize()
        {
            Database.DefaultConnectionFactory =
             new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");

            Database.SetInitializer<DataContext>(new DropCreateDatabaseIfModelChanges<DataContext>());
            this.Configuration.AutoDetectChangesEnabled = false;
        }
        
        public DbSet<PersoanaFizica> PersoaneFizice { get; set; }
        public DbSet<PersoanaJuridica> PersoaneJuridice { get; set; }
        public DbSet<Adresa> Adrese { get; set; }

    }
}
